//
//  HMComposeButton.swift
//  Weibo
//
//  Created by HM on 16/5/28.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit
private let imageHeight: CGFloat = 80

class HMComposeButton: UIButton {

    //添加模型
    var composeItem: HMComposeItem? {
        didSet {
            setImage(UIImage(named: composeItem?.icon ?? ""), forState: .Normal)
            setTitle(composeItem?.title, forState: .Normal)
            titleLabel?.textAlignment = .Center
            titleLabel?.font = UIFont.systemFontOfSize(14)
            setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        }
    }
   
    override func titleRectForContentRect(contentRect: CGRect) -> CGRect {
        return CGRect(x: 0, y: imageHeight, width: imageHeight, height: contentRect.height - imageHeight)
    }
    
    override func imageRectForContentRect(contentRect: CGRect) -> CGRect {
        return CGRect(x: 0, y: 0, width: imageHeight, height: imageHeight)
    }
}
